@extends('frontend/layouts/bootstrap')

@section('content')
<h2>Сэлбэг жагсаалт</h2>

{{-- FILTER --}}
<div class="well well-small">
    <form class="form-inline" style="margin: 0;" action="{{ route('car_balance.parts.list_filter') }}" method="post">
        {{-- AUCTION ID --}}
        <input class="input-small" id="auction-id" placeholder="Auction ID" type="text" name="auction_id" value="{{ $filters['auction_id'] ? $filters['auction_id'] : '' }}"/>
        {{-- PURCHASE DATE --}}
        <input class="input-small" id="form-date-range" placeholder="Date" type="text" name="purchase_date" id="daterange" value="{{ count($filters['purchase_date']) > 1 ? $filters['purchase_date'][0] .' - '.$filters['purchase_date'][1] : '' }}"/>
        {{-- CUSTOMER --}}
        @if (empty($customer))
        {{ Form::select('customer_id', $customer_list, $filters['customer_id'], array('class' => 'input-small')) }}
        @else
        {{ $customer->name }}
        @endif
        {{-- STATUS --}}
        <label for="cancelled">Only Cancelled:</label> <input id="cancelled" placeholder="Cancelled" type="checkbox" class="input-small" name="cancelled" {{ $filters['cancelled'] ? 'checked' : '' }}/>
        <label for="deleted">Include Deleted:</label> <input placeholder="Deleted" type="checkbox" id="deleted" class="input-small" name="deleted" {{ $filters['deleted'] ? 'checked' : '' }}/>

        {{ Form::token() }}
        {{-- BUTTONS --}}
        <button type="submit" class="btn">Apply Filter</button>
        <a href="?reset=1" >Reset</a>
    </form>
</div>

@if ($parts->count())
<div>{{ $parts->getTotal() }} results.</div>
<table class="table table-bordered table-condensed table-hover">
    <thead style="background-color: #f0f0f0;">
    <tr>
        <th title="Дугаар">#</th>
        <th title="Date">日付</th>
        <th title="Auction ID">Auction ID</th>
        <th title="Part name">Parts name</th>
        <th title="Seller">Seller</th>

        <!--<th title="Seller send type">販売店発送</th>
        <th title="Receive date">受信日</th>
        <th title="Pickup car chassis number">積込車両車体番号</th>
        -->
        <th title="Payment type">Payment type</th>
        <th title="Payment date">支払期日</th>
        <th title="Payment commission">入金手数料</th>
        <th title="Price">価格</th>
        <th title="Delivery">配送料</th>
        <th title="Commission">委員会</th>
        <th title="">Fee (mongol)</th>
        <th title="">Customer</th>

        <!--
        <th title="">Comment</th>-->

        <th style="width: 120px">Action</th>
    </tr>
    </thead>
    <tbody style="font-size: 11px;">
    @foreach($parts as $part)
    <tr>
        <td>{{ link_to_route('car_balance.parts.show', $part->id, $part->id, array()) }}</td>
        <td>{{ $part->purchase_date }}</td>
        <td>{{ $part->auction_id }}</td>
        <td>{{ $part->parts_name; }}</td>
        <td>{{ $part->seller; }}</td>

        <!--<td>{{ $part->seller_send_type; }}</td>
        <td>{{ $part->receive_date; }}</td>
        <td>{{ $part->pickup_car_chassis_no; }}</td>
        -->
        <td>{{ $part->payment_type }}</td>
        <td>{{ $part->payment_date }}</td>
        <td>{{ $part->payment_commission }}</td>
        <td>{{ $part->price }}</td>
        <td>{{ $part->delivery_fee }}</td>
        <td>{{ $part->commission }}</td>
        <td>{{ $part->fee_mongol }}</td>
        <td>{{ $part->customer ? link_to_route('car_balance.customer.show', $part->customer->name, $part->customer->id, array()) : 'NULL' }}</td>

        <!--
        <td>{{ $part->comment }}</td>-->

        <td>
            <a class="btn btn-primary btn-mini" href="{{ route('car_balance.parts.edit', $part->id) }}" title="Expenses"><i class="icon-dollar icon-white"></i></a>
            @if (!$part->isCancelled())
            <a class="btn btn-danger btn-mini" href="{{ route('car_balance.parts.cancel', $part->id) }}" onclick="if(!confirm('Are you sure?')) return false;" title="Cancel"><i class="icon-remove icon-white"></i></a>
            @else
            <a class="btn btn-danger btn-mini" href="{{ route('car_balance.parts.uncancel', $part->id) }}" onclick="if(!confirm('Are you sure?')) return false;" title="Undo Cancel"><i class="icon-undo icon-white"></i></a>
            @endif
            @if (!$part->Trashed())
            <a class="btn btn-danger btn-mini" href="{{ route('car_balance.parts.delete', $part->id) }}" onclick="if(!confirm('Are you sure?')) return false;" title="Delete"><i class="icon-trash icon-white"></i></a>
            @else
            <a class="btn btn-danger btn-mini" href="{{ route('car_balance.parts.restore', $part->id) }}" onclick="if(!confirm('Are you sure?')) return false;" title="Restore"><i class="icon-arrow-up icon-white"></i></a>
            @endif
        </td>
    </tr>
    @endforeach
    </tbody>
</table>

@include('nimo/domains/car_balance/page')

@else
    Хайлтад тохирох үр дүн алга
@endif

@stop


@section('pagestyles')
<link rel="stylesheet" type="text/css" href={{ asset('assets/chosen-bootstrap/chosen.min.css') }} />
<link rel="stylesheet" type="text/css" href={{ asset('assets/bootstrap-daterangepicker/daterangepicker.css') }} />
@stop

@section('pagescripts')
<!--page specific plugin scripts-->
<script type="text/javascript" src={{ asset('assets/chosen-bootstrap/chosen.jquery.min.js') }}></script>
<script type="text/javascript" src={{ asset('assets/bootstrap-daterangepicker/date.js') }} ></script>
<script type="text/javascript" src={{ asset('assets/bootstrap-daterangepicker/daterangepicker.js') }}></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input[name="purchase_date"]').daterangepicker({
            format:"yyyy-MM-dd"
        });
    });
</script>
@stop